package ${controllerUrl};

import com.baoyuan.basic.framework.rest.model.DataResult;
import com.baoyuan.framework.auth.authorize.clubAuth.NeedLogin;
import com.baoyuan.framework.auth.user.ExternalContext;
import com.baoyuan.framework.auth.user.UserContext;
import ${entityRequestUrl}.${entityRequestName};
import ${entityResponseUrl}.${entityResponseName};
import ${serviceUrl}.${entityName}Service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
<#if isSwagger=="true" >
</#if>

/**   
 *
 */
 <#if isSwagger=="true" >
</#if>
@RestController
@RequestMapping("/${objectName}")
public class ${entityName}Controller {
    @Autowired
	private ${entityName}Service service;

    /**
    * 保存
    * @param request
    * @return
    */
    @NeedLogin
    @PostMapping(value = "/save")
    public DataResult<Long> save(@RequestBody ${entityRequestName} request) {
        Long tenantId = ExternalContext.currentExternal().getTenantId();
        Long operatorId = UserContext.userId();
        Long id = service.save(${saveMethodParamsIn});
        return DataResult.ok(id);
    }

    /**
    * 根据 id 查询详情
    * @param id
    * @return
    */
    @NeedLogin
    @GetMapping(value = "/find-detail")
    public DataResult<${entityResponseName}> findDetail(Long id) {
        ${entityResponseName} response = service.findResponseById(id);
        return DataResult.ok(response);
    }
}